import { Context } from "koa";
import CategoryService from "../services/category.service";

class CategoryController {
  static async listCategories(ctx: Context) {
    try {
      const list = await CategoryService.listCategories();

      ctx.body = {
        code: 200,
        message: "获取分类列表成功",
        data: list,
      };
    } catch (error) {
      ctx.body = {
        code: 500,
        message: "获取分类列表失败",
        data: null,
      };
    }
  }
}

export default CategoryController;
